package com.iran.calculator.strategy;


import com.iran.calculator.strategy.impl.NormalCash;
import com.iran.calculator.strategy.impl.RebateCash;
import com.iran.calculator.strategy.impl.ReturnCash;

/**
 * 定义了一系列可重用的算法或者行为
 */
public class CashContext {
    private ISuperCash superCash;

    public CashContext(String type) {
        switch (type) {
            case "打八折":
                superCash = new RebateCash(0.8d);
                break;
            case "打七折":
                superCash = new RebateCash(0.7d);
                break;
            case "满三百减一百":
                superCash = new ReturnCash(300d, 100d);
                break;
            default:
                superCash = new NormalCash();
                break;
        }
    }

    public double getResult(double money){
        return superCash.acceptCash(money);
    }
}
